Skip to content

AAP-70294: Migrate Unit Test Candidates from ATF to Upstream#16385

Open
jessicamack wants to merge 3 commits intoansible:develfrom
jessicamack:move-over-atf-unit-tests
Open

AAP-70294: Migrate Unit Test Candidates from ATF to Upstream#16385
jessicamack wants to merge 3 commits intoansible:develfrom
jessicamack:move-over-atf-unit-tests

Conversation

@jessicamack
Copy link
Copy Markdown
Member

@jessicamack jessicamack commented Apr 1, 2026

SUMMARY

There are tests in controller-test-suite that are currently written as integration tests but can be rewritten as unit/functional tests in tower. This PR is adding some of those identified tests.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Other

Summary by CodeRabbit

  • Tests
    • Added comprehensive functional tests for inventory and notification template name uniqueness validation across organizations.
    • Added functional test to verify bulk job launch requests respect the configurable system limit.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Three new functional tests were added to verify API constraint behaviors: inventory names must be unique per organization, notification template names must be unique per organization, and bulk job launch requests respect a configurable system limit setting.

Changes

Cohort / File(s) Summary
API Functional Tests
awx/main/tests/functional/api/test_inventory.py, awx/main/tests/functional/api/test_notification_templates.py
Added tests verifying name uniqueness constraints scoped to organization. Both tests validate that identical names are permitted across different organizations but rejected (HTTP 400) when duplicated within the same organization, with appropriate error messages.
Bulk Job Functional Tests
awx/main/tests/functional/test_bulk.py
Added test verifying bulk job launch requests respect the BULK_JOB_MAX_LAUNCH system limit, enforcing HTTP 400 rejection when requests exceed the configured threshold and HTTP 201 success when within limits.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the changeset: migrating test candidates from ATF to upstream, which aligns with the three new functional tests being added to the awx repository.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jessicamack jessicamack enabled auto-merge (squash) April 1, 2026 21:27
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
awx/main/tests/functional/test_bulk.py (1)

2-2: Unused import.

The mock import is not used anywhere in the file.

🧹 Proposed fix
-from unittest import mock
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@awx/main/tests/functional/test_bulk.py` at line 2, Remove the unused import
"mock" from the top of the test file: delete the "from unittest import mock"
import statement (the only reference is the symbol "mock") so the module no
longer contains an unused import; run tests to verify nothing else depends on
"mock" in this file.
awx/main/tests/functional/api/test_notification_templates.py (1)

1-92: LGTM!

Well-structured test that mirrors the inventory uniqueness test pattern. The test correctly validates the organization-scoped uniqueness constraint for notification template names, covering both allowed (cross-org) and rejected (same-org duplicate) scenarios.

Minor optional suggestion: The notification_configuration dict is repeated three times. Consider extracting it to a local variable to reduce duplication:

notification_config = {
    'username': 'user@example.com',
    'password': 'pass',
    'sender': 'sender@example.com',
    'recipients': ['recipient@example.com'],
    'host': 'smtp.example.com',
    'port': 25,
    'use_tls': False,
    'use_ssl': False,
}

This is purely a readability/maintainability improvement and not blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@awx/main/tests/functional/api/test_notification_templates.py` around lines 1
- 92, Extract the repeated notification_configuration dict used in
test_notification_template_names_unique_per_organization into a single local
variable (e.g., notification_config) and reuse it in the three post(...) calls
to reduce duplication and improve readability; update each post payload to pass
that variable for the 'notification_configuration' key and keep all other fields
and assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@awx/main/tests/functional/api/test_notification_templates.py`:
- Around line 1-92: Extract the repeated notification_configuration dict used in
test_notification_template_names_unique_per_organization into a single local
variable (e.g., notification_config) and reuse it in the three post(...) calls
to reduce duplication and improve readability; update each post payload to pass
that variable for the 'notification_configuration' key and keep all other fields
and assertions unchanged.

In `@awx/main/tests/functional/test_bulk.py`:
- Line 2: Remove the unused import "mock" from the top of the test file: delete
the "from unittest import mock" import statement (the only reference is the
symbol "mock") so the module no longer contains an unused import; run tests to
verify nothing else depends on "mock" in this file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1dcc5e42-6c3c-4ed3-9993-ac7a69bb6fc3

📥 Commits

Reviewing files that changed from the base of the PR and between e80ce43 and f918924.

📒 Files selected for processing (3)
  • awx/main/tests/functional/api/test_inventory.py
  • awx/main/tests/functional/api/test_notification_templates.py
  • awx/main/tests/functional/test_bulk.py

tvo318
tvo318 previously requested changes Apr 1, 2026
Copy link
Copy Markdown
Member

@tvo318 tvo318 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think everything else looks alright.. once you commit the changes, let's see how the CI checks go and I can approve.

@jessicamack jessicamack requested a review from tvo318 April 2, 2026 09:27
Copy link
Copy Markdown
Contributor

@adrisala adrisala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving my comments here. I'm missing some tests from ATF:

  • I don't see anything for test_pagination
  • For test_bulk_api I see the test added bears no relation with the tests in the ATF file (test_bulk_job_launch_respects_settings_limit and the ATF test had test_create_hosts, test_launch_jobs, test_create_multiple_jobs_after_modifying_settings

Are these tested somewhere else in the tower repo? I want to be sure we're not losing coverage with this

@jessicamack
Copy link
Copy Markdown
Member Author

@adrisala

@jessicamack jessicamack requested a review from adrisala April 2, 2026 12:31
@jessicamack jessicamack dismissed tvo318’s stale review April 2, 2026 13:25

The requested change has been made.

@jessicamack jessicamack force-pushed the move-over-atf-unit-tests branch from b2103dc to 879bd22 Compare April 2, 2026 13:39
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants